package day7;

import java.util.Scanner;

public class TestStudent {
    public static void main(String[] args) {
        StudentBiz studentBiz = new StudentBiz();
        Scanner input = new Scanner(System.in);
        while(true) {
            System.out.print("输入学生姓名：");
            String name = input.next();
            if("n".equals(name)) break;
            Student student = new Student();
            student.name = name;
            studentBiz.add(student);
        }
        studentBiz.printStudents();
        System.out.print("请输入要查找的起始位置:");
        int pos1 = input.nextInt();
        System.out.print("请输入要查找的结束位置:");
        int pos2 = input.nextInt();
        System.out.print("请输入要查找的名称:");
        String searchName = input.next();
        Student student = studentBiz.search(pos1, pos2, searchName);
        System.out.println(student == null ? "没找到" : "找到了");
        System.out.print("请输入要替换的旧名称:");
        String oldName = input.next();
        System.out.print("请输入要替换的新名称:");
        String newName = input.next();
        System.out.println(studentBiz.replace(oldName, newName));

        studentBiz.printStudents();
    }
}
